package com.haiyangwang1.lesson12.ex1;

import java.util.Scanner;

public class Game {
    Scanner input=new Scanner(System.in);
    public String getResult(){
        int win=0;
        int lose=0;
        int draw=0;

        Person p=new Person();
        Computer c=new Computer();
        Choose choose=new Choose();


        while (true){
            p.showPersonFist();
            choose.choose();
            c.showCompuerFist();

            if((p.personFist==1&&c.computerFist==3)||
                    (p.personFist==2&&c.computerFist==1)||
                    (p.personFist==3&&c.computerFist==2)){
                System.out.println("恭喜你，你赢了");
                win++;
            } else if ((c.computerFist==1&&p.personFist==2)||
                    (c.computerFist==2&&p.personFist==3)||
                    (c.computerFist==3&&p.personFist==1)) {
                System.out.println("小笨蛋，你输了");
                lose++;
            }else {
                System.out.println("打平了");
                draw++;
            }
            String answer="y";
            System.out.println("请问是否需要继续，y/n");
            answer=input.next();
            if (answer.equalsIgnoreCase("n")){
                break;
            }

        }
        System.out.println("一共玩了"+(win+lose+draw)+"盘赢了"+win+"次输了"+lose+"次平了"+draw+"次");
        return "";
    }
}
